package com.platform.hjt.erp.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.platform.hjt.base.controller.ReturnBody;
import com.platform.hjt.base.service.BaseService;

import com.platform.hjt.erp.dao.ErpOrderInfoDAO;
import com.platform.hjt.erp.model.ErpOrderInfo;

import com.hjt.tools.dao.Page;
import com.hjt.tools.dao.PropertyFilter;

@Service
public class ErpOrderInfoService extends BaseService{

	@Resource
	private ErpOrderInfoDAO erpOrderInfoDAO;
	
	public ReturnBody saveErpOrderInfo(ErpOrderInfo erpOrderInfo){
		if(StringUtils.isNotBlank(erpOrderInfo.getErpOrderInfoId())){
			erpOrderInfoDAO.updatePerproties(erpOrderInfo);
			return  new ReturnBody(true, "更新成功");
		}else{
			 erpOrderInfoDAO.saveJ(erpOrderInfo);
			return  new ReturnBody(true, "添加成功");
		}
	}
	
	public ReturnBody delErpOrderInfo(ErpOrderInfo erpOrderInfo){
		erpOrderInfo.setIsDel(true);
		erpOrderInfoDAO.updatePerproties(erpOrderInfo);
		return  new ReturnBody(true, "删除成功");
	}
	
	public Page<ErpOrderInfo> getErpOrderInfoList(Page<ErpOrderInfo> page, List<PropertyFilter> propertyFilterList){
		return erpOrderInfoDAO.findPage(page, propertyFilterList);
	}
	
	public List<ErpOrderInfo> getErpOrderInfoList(List<PropertyFilter> filters){
		return erpOrderInfoDAO.find(filters);
	}
	
	public ErpOrderInfo getErpOrderInfo(List<PropertyFilter> filters){
		return erpOrderInfoDAO.findUniqueBy(filters);
	}
	
	public ErpOrderInfo getErpOrderInfo(String propertyName, Object value){
		return erpOrderInfoDAO.findUniqueBy(propertyName, value);
	}
	
}
